﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Easy.DAL;

namespace Easy.Web.ISV.XMLProcess
{
    /// <summary>
    /// Solutionxmlload 的摘要说明
    /// </summary>
    public class Solutionxmlload : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Dictionary<string, object> Responsedata = new Dictionary<string, object>();
            try
            {
                Xmlload dtx = new Xmlload();
                string entityname = context.Request["entityname"];
                Guid formid = new Guid(context.Request["formid"]);
                bool b = dtx.DataToXml(entityname, formid);
                if (b)
                {
                    Responsedata.Add("message", "下载成功！");
                    Responsedata.Add("code", '0');
                }
                else
                {
                    Responsedata.Add("message", "下载失败！");
                    Responsedata.Add("code", '1');
                }
                

            }
            catch (Exception ex)
            {
                Responsedata.Add("message", "下载失败！" + ex.Message);
                Responsedata.Add("code", '1');

            }
            context.Response.Write(JsonConvert.SerializeObject(Responsedata));
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}